package com.aooci.ordercat.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@Table(name = "ITEM")
@NamedQueries({
    @NamedQuery(name="ITEM.selectByItemCategoryId",
                query="SELECT new com.aooci.ordercat.vo.ItemVo(t.id, t.itemCategory.id, t.itemCategory.sortGroup, t.label, t.name, t.unitPrice) FROM Item t WHERE t.itemCategory.id = :itemCategoryId ORDER BY t.label"),
    @NamedQuery(name="ITEM.selectAll",
                query="SELECT new com.aooci.ordercat.vo.ItemVo(t.id, t.itemCategory.id, t.itemCategory.sortGroup, t.label, t.name, t.unitPrice) FROM Item t ORDER BY t.label"),
    @NamedQuery(name="ITEM.findByLabel",
                query="SELECT t FROM Item t WHERE t.label = :label"),
}) 
public class Item extends IdentityEntity implements Serializable {

	private static final long serialVersionUID = 1L;
	
	@Column(name = "LABEL")
	private String label;
	
	@Column(name = "NAME")
	private String name;

	@Column(name = "UNIT_PRICE")
	private float unitPrice;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "ITEM_CATEGORY_ID")
	private ItemCategory itemCategory;

	@Column(name = "PRINT_KITCHEN")
	private boolean printKitchen;

	/**
	 * @return the label
	 */
	public String getLabel() {
		return label;
	}

	/**
	 * @param label the label to set
	 */
	public void setLabel(String label) {
		this.label = label;
	}

	/**
	 * @return the unitPrice
	 */
	public float getUnitPrice() {
		return unitPrice;
	}

	/**
	 * @param unitPrice the unitPrice to set
	 */
	public void setUnitPrice(float unitPrice) {
		this.unitPrice = unitPrice;
	}

	/**
	 * @return the itemCategory
	 */
	public ItemCategory getItemCategory() {
		return itemCategory;
	}

	/**
	 * @param itemCategory the itemCategory to set
	 */
	public void setItemCategory(ItemCategory itemCategory) {
		this.itemCategory = itemCategory;
	}

	/**
	 * @return the printKitchen
	 */
	public boolean isPrintKitchen() {
		return printKitchen;
	}

	/**
	 * @param printKitchen the printKitchen to set
	 */
	public void setPrintKitchen(boolean printKitchen) {
		this.printKitchen = printKitchen;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}
